<?php
error_reporting(E_ALL ^ E_NOTICE);// 关闭当前文件中的 notice 警告
require_once("DButil.php");
header("Access-Control-Allow-Origin:*");
header("Content-Type:application/json;charset=UTF-8");

$courseId = $_REQUEST["courseId"];
$teacherId = $_REQUEST["teacherId"];
$status = $_REQUEST["status"];
$videoId = $_REQUEST["videoId"];

$sql = "select v.* from t_video v "
. " inner join t_teacher t on t.teacherId = v.teacherId "
. " inner join t_course c on c.courseId = v.courseId "
. " where 1 = 1 ";

if(!empty($courseId)){
    $sql .= "and v.courseId = '$courseId' ";
}
if(!empty($teacherId)){
    $sql .= "and v.teacherId = '$teacherId' ";
}
if($status == '0' || !empty($status)){
    $sql .= "and v.status = '$status' ";
}
if(!empty($videoId)){
    $sql .= "and v.videoId = '$videoId' ";
}
// echo $sql;
$result = query(getConn(), $sql);

$arr = [
    "success" => true,
    "msg" => "查询成功",
    "data" => $result["data"]
];
echo json_encode($arr);
?>